<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>固定定位案例</title><style>
body {
    height: 3000px;
}
.nav {
    /* 粘性导航栏sticky应用 */
    position: sticky;
    /* 必须给边偏移才起作用 */
    top: 0;


    width: 800px;
    height: 50px;
    background-color: blue;
    margin: 50px auto;
}
 .gg1 { 
     position: fixed;
     top: 150px;
     left: 0;
      /* 固定定位fixed：距上150px 靠左对齐 */
     width: 150px;
     height: 300px;
     background-color: pink;
}
.gg2 {
    position: fixed;
    top: 150px;
    right: 0;
     /* 固定定位fixed：距上150px 靠右对齐 */
    width: 150px;
     height: 300px;
     background-color:skyblue;

}
    </style>
   
</head>
<body>
    <div class="nav">我是导航栏</div>
    <div class="gg1"></div>
    <div class="gg2"></div>
</body>
</html>